﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace DatabaseTunning
{
    /// <summary>
    /// Convert an object to formatted string.
    /// </summary>
    public class ObjectToFormatStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                string format = parameter.ToString();
                return string.Format(format, value);
            }
            catch
            {
                return value == null ? DependencyProperty.UnsetValue : value.ToString();
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }
}